package santeclair.connexion.webservice.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import santeclair.connexion.domaine.parametrage.Service;
import santeclair.connexion.parametrage.dto.ServiceDto;
import santeclair.connexion.parametrage.webservice.ServiceWebService;
import santeclair.connexion.service.parametrage.ServiceService;
import santeclair.lunar.framework.util.BeanUtils;

/**
 * @see ServiceWebService
 * 
 * @author fmokhtari
 */
@org.springframework.stereotype.Service
public class ServiceWebServiceImpl implements ServiceWebService {

    @Autowired
    private ServiceService serviceService;

    @Override
    public ServiceDto getService(Integer idService) {
        return BeanUtils.copyProperties(serviceService.getService(idService), ServiceDto.class);
    }

    @Override
    public List<ServiceDto> getListeServices() {
        List<Service> listeServices = serviceService.getListeServices();
        List<ServiceDto> listeServicesDtos = new ArrayList<>();
        for (Service service : listeServices) {
            listeServicesDtos.add(BeanUtils.copyProperties(service, ServiceDto.class));
        }
        return listeServicesDtos;
    }

}
